home *** CD-ROM | disk | FTP | other *** search
/ 64'er / 64ER_CD.iso / 93xx / 9301.d64 / magische quadr. (.txt) < prev    next >
Commodore BASIC  |  1995-03-30  |  831b  |  20 lines

  1. 0 INPUT"[147]GROESSE";L:DIMA%(L,L):GOSUB5:S=L*(L*L+1)/2:INPUT"GA";G:INPUT"SA";T
  2. 1 INPUT"NAME";N$:A=LEN(STR$(L*L)):IFG=3THENA=3:R$(1)="[144]":R$(.)=""
  3. 2 PRINT"[147]":OPEN1,G,T,N$:CMD1:L$="    ":FORY=1TOL:FORX=1TOL:PRINTR$(X+YAND1);
  4. 3 PRINTRIGHT$(L$+STR$(A%(X,Y)),A);:NEXT:PRINT:NEXT:PRINT:PRINT"SUMME:"S
  5. 4 PRINT#1,"";:CLOSE1:END:DATA1,1,,,1,1,,,,,1,1,,,1,1
  6. 5 POKE53280,12:POKE53281,12:IFL/2>INT(L/2)THEN14
  7. 6 FORX=.TO3:FORY=.TO3:READA(X,Y):NEXT:NEXT:IFL/4>INT(L/4)THEN9
  8. 7 FORX=1TOL:FORY=1TOL:A%(X,Y)=X+Y*L-L:IFA(XAND3,YAND3)THENA%(X,Y)=L*L+1-A%(X,Y)
  9. 8 NEXT:NEXT:RETURN
  10. 9 L=L/2:GOSUB5:FORX=1TOL:FORY=1TOL:A%(X+L,Y+L)=A%(X,Y)+L*L
  11. 10 A%(X+L,Y)=A%(X,Y)+2*L*L:A%(X,Y+L)=A%(X,Y)+3*L*L:NEXT:NEXT:FORY=1TOL
  12. 11 FORX=1TOL/2-.5:GOSUB13:NEXT:IFL>3THENFORX=1.5*L+2.5TO2*L:GOSUB13:NEXT
  13. 12 NEXT:Y=L/2+.5:X=1:GOSUB13:X=Y:GOSUB13:L=L+L:RETURN
  14. 13 H=A%(X,Y):A%(X,Y)=A%(X,Y+L):A%(X,Y+L)=H:RETURN
  15. 14 X=L/2+.5:Y=L/2-.5:W=1
  16. 15 A%(X,Y)=W:X=X+1:Y=Y-1:IFX=L+1ANDY=.THENX=L:Y=L-1
  17. 16 X=X+L*(X>L):Y=Y-L*(Y<1):IFA%(X,Y)THENY=Y-1-L*(Y<2):X=X-1
  18. 17 W=W+1:IFW>L*LTHENRETURN
  19. 18 GOTO15
  20.